﻿//盛金龙
var frm = {};
frm.show = {};
frm.dalog = {};
frm.show = function(title, str, w, h) {
    frm.dalog = art.dialog.open(str, { title: title, width: w, height: h, id: title });
}
//与数据库交互
var Connection = {};
//编辑环境
Connection.Edit = function(obj) {
    EnvironmentManagerSystem.HuanJing.HuanJing_Tabone.EditTable(obj.id, obj.value, Connection.AjaxEdit);
}
Connection.AjaxEdit = function(str) {
if (!str.value && str.value != null && str.value != undefined) {
        alert("请输入正确的经纬度格式。例如:00度00分00秒或00°00′00");
    }
}
Connection.AjaxEdita = function(str) {
    if (!str.value && str.value != null && str.value != undefined) {
        alert("项目已存在");
    }
}
Connection.CheckBox = function(obj) {
    var ary = document.getElementsByTagName("input");
    var CValue = "";
    for (var i = 0; i < ary.length; i++) {
        var cbo = ary[i];
        if (cbo.type == "checkbox" && cbo.checked) {
            CValue += cbo.id + ",";
        }
    }
    EnvironmentManagerSystem.HuanJing.HuanJing_Tabone.EditTable("huanjingmingantexing", CValue, Connection.AjaxEdit);
}
//编辑生态
Connection.EditShengTai = function(obj) {
    EnvironmentManagerSystem.HuanJing.HuanJing_Tabtwo.EditTable(obj.id, obj.value, Connection.AjaxEdit);
}
//项目信息
Connection.PjTest = function(obj) {
    if (obj.a == "true" || obj.type == "radio") {
        if (obj.value != "") {
            if (document.getElementById("tbs001_developprojectbasicinfo_ProjectName").value != "") {
                if (obj.id.indexOf("tbs001_developprojectbasicinfo") >= 0) {
                    if (obj.id == "tbs001_developprojectbasicinfo_ProjectName") {
                    }
                    else {
//                        if (obj.id == "tbs001_developprojectbasicinfo_r4" || obj.id == "tbs001_developprojectbasicinfo_r5" || obj.id == "tbs001_developprojectbasicinfo_r6") {
//                            EnvironmentManagerSystem.HuanJing.HuanJing_Tabthree.EditTable("Report", obj.value, "false", document.getElementById("tbs001_developprojectbasicinfo_ProjectName").value, Connection.AjaxEdita);
//                            //EnvironmentManagerSystem.HuanJing.HuanJing_Tabthree.BindHuanPing(obj.value);
//                        }
                        if (obj.id == "tbs001_developprojectbasicinfo_r1" || obj.id == "tbs001_developprojectbasicinfo_r2" || obj.id == "tbs001_developprojectbasicinfo_r3") {
                            EnvironmentManagerSystem.HuanJing.HuanJing_Tabthree.EditTable("DevelopState", obj.value, "false", document.getElementById("tbs001_developprojectbasicinfo_ProjectName").value, Connection.AjaxEdita);
                        }

                        else if (obj.id == "tbs001_developprojectbasicinfo_jingdu" || obj.id == "tbs001_developprojectbasicinfo_weidu") {
                            EnvironmentManagerSystem.HuanJing.HuanJing_Tabthree.EditTable((obj.id).substring(obj.id.lastIndexOf("_") + 1, obj.id.length), obj.value, "false", document.getElementById("tbs001_developprojectbasicinfo_ProjectName").value,Connection.AjaxEdit);
                        }
                        else if(obj.id == "tbs001_developprojectbasicinfo_EnvironmentalInvestmentProportion" || obj.id == "tbs001_developprojectbasicinfo_Investment" )
                        {
                        try
                        {
                        var i = Number(document.getElementById("tbs001_developprojectbasicinfo_EnvironmentalInvestmentProportion").value);
                        var ii = Number(document.getElementById("tbs001_developprojectbasicinfo_Investment").value);
                        if(Number(i/ii) >0 )
                        {
                        if(document.getElementById("tbs001_developprojectbasicinfo_EnvironmentalInvestmentProportion").value!="" && document.getElementById("tbs001_developprojectbasicinfo_Investment").value!=""){
           document.getElementById("tbs001_developprojectbasicinfo_GPSE").value=(Math.round(parseFloat(i/ii) * 10000) / 100)+"%";
                        document.getElementById("tbs001_developprojectbasicinfo_GPSE").onblur();
                        }
                         EnvironmentManagerSystem.HuanJing.HuanJing_Tabthree.EditTable((obj.id).substring(obj.id.lastIndexOf("_") + 1, obj.id.length), obj.value, "false", document.getElementById("tbs001_developprojectbasicinfo_ProjectName").value, Connection.AjaxEdita);
                        }
                        else 
                        {
                         alert('输入错误');obj.value="";
                        }
                        }
                        catch(e){alert('输入错误');this.valueOf="";}
                        }
                        else
                            EnvironmentManagerSystem.HuanJing.HuanJing_Tabthree.EditTable((obj.id).substring(obj.id.lastIndexOf("_") + 1, obj.id.length), obj.value, "false", document.getElementById("tbs001_developprojectbasicinfo_ProjectName").value, Connection.AjaxEdita);
                    }
                }
            }
            else {
                alert("首先填写项目名称");
                obj.value = "";
            }
        }
    }
}

//项目负责人下拉列表事件
Connection.DropList0 = function(obj,str) {
    if (document.getElementById("tbs001_developprojectbasicinfo_ProjectName").value != "") {
        EnvironmentManagerSystem.HuanJing.HuanJing_Tabthree.SelectList3Value(obj.value, document.getElementById("tbs001_developprojectbasicinfo_ProjectName").value,str, Connection.Bing0);
    }
    else {
        alert("首先填写项目名称");
        obj.selectedIndex = 0;
    }
}
//项目负责人数据绑定
Connection.Bing0 = function(val) {
}

//项目保存项目提交
Connection.save=function(str)
{
EnvironmentManagerSystem.HuanJing.HuanJing_Tabthree.DbSave(document.getElementById("tbs001_developprojectbasicinfo_ProjectName").value,str);
    alert("操作完成");
    var win = window.parent.parent.parent;
	win.document.frames[0].location.href="HuanJing_main.aspx"
}

